from selenium import webdriver
from selenium.webdriver.edge.options import Options
from selenium.webdriver.common.by import By
import time


# 设置浏览器、启动浏览器
def create_driver():
    options = Options()
    options.add_argument('--no-sandbox')
    options.add_experimental_option("detach", True)
    driver_edge = webdriver.Edge(options=options)
    return driver_edge
driver = create_driver()


driver.get("https://baidu.com")
# 元素定位 - TAG_NAME
# 1. 查找<开头标签名>
# 2. 重复标签名特别多,需要切片

a_list = driver.find_elements(By.TAG_NAME, 'a')
for a in a_list:
    print(a.text)

# 列表切片获取元素
a_list[3].click()


